home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Object Oriented Applicat…isualAge for C++ for OS/2
/
Object-Oriented Application Development with VisualAGE for C++ for OS2.iso
/
creatab.ddl
next >
Wrap
Text File
|
1996-02-26
|
5KB
|
177 lines
CREATE TABLE USERID.BUYER
(BUYER_ID CHAR(11) NOT NULL,
FIRST_NAME CHAR(20) NOT NULL,
LAST_NAME CHAR(20) NOT NULL,
MARRITAL_STATUS CHAR(1),
GENDER CHAR(1),
INCOME DECIMAL(15,2),
WORK_PHONE CHAR(12),
HOME_PHONE CHAR(12),
PRIMARY KEY (BUYER_ID));
CREATE TABLE USERID.BUYER_ADDRESS
(ADDRESS_ID CHAR(11) NOT NULL,
STREET CHAR(40) NOT NULL,
AREA CHAR(40) NOT NULL,
CITY CHAR(40) NOT NULL,
STATE CHAR(2),
ZIP_CODE CHAR(5) FOR BIT DATA,
PRIMARY KEY ( ADDRESS_ID ));
CREATE TABLE USERID.BUYER_LOG
(BUYER_ID CHAR(11) NOT NULL,
CREATION_TIMESTAMP TIMESTAMP,
LAST_UPDATE TIMESTAMP,
PRIMARY KEY ( BUYER_ID ));
CREATE TABLE USERID.MARKETING_INFO
(PROPERTY_ID CHAR(5) NOT NULL,
PRICE DECIMAL(7,0) NOT NULL,
DAYS_ON_MARKET SMALLINT,
COMMISSION_RATE DECIMAL(5,2),
DOWN_PAYMENT_RATE DECIMAL(5,2),
PRIMARY KEY ( PROPERTY_ID ));
CREATE TABLE USERID.MULTIDOC
(MULTIDOC_ID CHAR(5) NOT NULL,
FILENAME VARCHAR(254) NOT NULL,
TYPE CHAR(20) NOT NULL,
PRIMARY KEY (MULTIDOC_ID));
CREATE TABLE USERID.PREFERENCE
(BUYER_ID CHAR(11) NOT NULL,
MAX_PRICE DECIMAL(15,2),
MIN_PRICE DECIMAL(15,2),
MAX_SIZE DECIMAL(15,2),
MIN_SIZE DECIMAL(15,2),
BEDROOMS SMALLINT,
BATHROOMS SMALLINT,
STORIES SMALLINT,
HEATING CHAR(30),
COOLING CHAR(30),
PRIMARY KEY (BUYER_ID));
CREATE TABLE USERID.PROPERTY
(PROPERTY_ID CHAR(5) NOT NULL,
SIZE DECIMAL(5,0) NOT NULL,
BEDROOMS SMALLINT NOT NULL,
BATHROOMS SMALLINT NOT NULL,
STORIES SMALLINT NOT NULL,
COOLING CHAR(30) NOT NULL,
HEATING CHAR(30) NOT NULL,
DESCRIPTION VARCHAR(512),
PRIMARY KEY (PROPERTY_ID));
CREATE TABLE USERID.PROPERTY_ADDRESS
(ADDRESS_ID CHAR(5) NOT NULL,
STREET CHAR(40) NOT NULL,
AREA CHAR(40),
CITY CHAR(40) NOT NULL,
STATE CHAR(2),
ZIP_CODE CHAR(5) FOR BIT DATA,
PRIMARY KEY (ADDRESS_ID));
CREATE TABLE USERID.PROPERTY_LOG
(PROPERTY_ID CHAR(5) NOT NULL,
DOWNLOAD_TIMESTAMP TIMESTAMP NOT NULL,
LAST_UPDATE TIMESTAMP NOT NULL,
STATUS CHAR(15) NOT NULL,
PRIMARY KEY (PROPERTY_ID));
CREATE TABLE USERID.SALE_TRANSACTION
(TRANSACTION_ID TIMESTAMP NOT NULL,
LAST_UPDATE TIMESTAMP NOT NULL,
AGREEMENT_FORM_ID INTEGER NOT NULL,
STATUS CHAR(10) NOT NULL,
BUYER_ID CHAR(11) NOT NULL,
PROPERTY_ID CHAR(5) NOT NULL,
PRIMARY KEY (TRANSACTION_ID));
CREATE VIEW USERID.BUYER_INFO
(BUYER_ID,
FIRST_NAME,
LAST_NAME,
INCOME,
WORK_PHONE,
HOME_PHONE,
STREET,
AREA,
CITY,
STATE,
ZIP_CODE,
MAX_PRICE,
MIN_PRICE,
MAX_SIZE,
MIN_SIZE,
BEDROOMS,
BATHROOMS,
STORIES,
HEATING,
COOLING)
AS SELECT A.BUYER_ID,
FIRST_NAME,
LAST_NAME,
INCOME,
WORK_PHONE,
HOME_PHONE,
STREET,
AREA,
CITY,
STATE,
ZIP_CODE,
MAX_PRICE,
MIN_PRICE,
MAX_SIZE,
MIN_SIZE,
BEDROOMS,
BATHROOMS,
STORIES,
HEATING,
COOLING
FROM USERID.BUYER A,
USERID.BUYER_ADDRESS B,
USERID.PREFERENCE C
WHERE (A.BUYER_ID=ADDRESS_ID
AND A.BUYER_ID=C.BUYER_ID);
CREATE VIEW USERID.PROP_AD_LOG
(PROPERTY_ID,
SIZE,
BEDROOMS,
BATHROOMS,
AREA,
CITY,
STATE,
STATUS,
PRICE,
COMMISSION_RATE,
DOWN_PAYMENT_RATE)
AS SELECT A.PROPERTY_ID,
SIZE,
BEDROOMS,
BATHROOMS,
AREA,
CITY,
STATE,
STATUS,
PRICE,
COMMISSION_RATE,
DOWN_PAYMENT_RATE
FROM USERID.PROPERTY A,
USERID.PROPERTY_ADDRESS B,
USERID.PROPERTY_LOG C,
USERID.MARKETING_INFO D
WHERE (A.PROPERTY_ID=ADDRESS_ID AND
A.PROPERTY_ID=C.PROPERTY_ID AND
A.PROPERTY_ID=D.PROPERTY_ID);
CREATE VIEW USERID.LIST_AREA
(AREA)
AS SELECT DISTINCT AREA
FROM USERID.PROPERTY_ADDRESS A,
USERID.PROPERTY_LOG B
WHERE (ADDRESS_ID=PROPERTY_ID) AND
((STATUS='AVAILABLE'));